import request from "@/utils/request";
import type {
  HospitalResponseData,
  HospitalLevelAndRegionResponseData,
  HospitalInfo,
} from "./type";

// 通过枚举管理API
enum API {
  // 请求医院信息列表的接口
  HOSPITAL_URL = "/hosp/hospital/",
  //获取等级或者区域数据
  HOSPITALLEVELANDREGION_URL = "/cmn/dict/findByDictCode/",
  //根据关键字医院的名字获取数据
  HOSPITALINFO_URL = "/hosp/hospital/findByHosname/",
}
// 请求医院信息列表的接口
//当前页码，页码条数，医院等级，医院区域代码
export const reqHospital = (
  page: number,
  limit: number,
  hostype: string = "",
  districtCode: string = ""
) =>
  request.get<any, HospitalResponseData>(
    API.HOSPITAL_URL +
      `${page}/${limit}?hostype=${hostype}&districtCode=${districtCode}`
  );

//   获取等级或者区域数据
export const reqLevelOrRegion = (DictCode: string) =>
  request.get<any, HospitalLevelAndRegionResponseData>(
    API.HOSPITALLEVELANDREGION_URL + DictCode
  );
//根据医院关键字信息查询相关信息
export const reqHospitalInfo = (hosname: string) =>
  request.get<any, HospitalInfo>(API.HOSPITALINFO_URL + hosname);
